<?php

namespace App\Libraries\Entities;

trait HasStatus
{
    protected $StatusFlag = false;

    public function useStatus()
    {
        return $this->StatusFlag;
    }

    public function setStatus()
    {
        $message = '';
        if (!is_null(static::STATUS) && !$this->isDirty(static::STATUS)) {
            if ($this->{static::STATUS}) {
                $message = $this->disable();
            } else {
                $message = $this->enable();
            }
        }

        return $message;
    }

    protected function enable()
    {
        $this->{static::STATUS} = 1;

        return '启用';
    }

    protected function disable()
    {
        $this->{static::STATUS} = 0;

        return '禁用';
    }
}
